﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Device.Location;
using System.Linq;
using System.Text;

namespace RutoDeBaredDatabase
{
    public class Database : DataContext
    {

        // Pass the connection string to the base class. 
        public Database(string connectionString)
            : base(connectionString)
        {
            //if (Routes == null)
            //Routes = new Table<Route>{new Route(BeschrijvingENG = "iets")};

        }

        public Table<Route> Routes;
        public Table<Bezienswaardigheid> Bezienswaardigheiden;
        public Table<Bezienswaardigheid_Route> Bezienswaardigheidroute;

        // LET OP!!
        // je moet de database op zo'n manier aanroepen:
        // new Database(@"Data Source=isostore:/BestandsNaam.sdf");




        [Table]
        public class Route : INotifyPropertyChanged, INotifyPropertyChanging
        {
            // Define ID: private field, public property, and database column.
            private string _BeschrijvingENG;
            private string _BeschrijvingNL;
            private string _TitelENG;
            private string _TitelNL;
            private string _Stad;


            [Column(IsPrimaryKey = true, IsDbGenerated = true, AutoSync = AutoSync.OnInsert)]
            public int RouteSleutel
            {
                get;
                internal set;
            }

            [Column]
            public String Stad
            {
                get { return _Stad; }
                set
                {
                    NotifyPropertyChanging("Stad");
                    _Stad = value;
                    NotifyPropertyChanged("Stad");
                }
            }
            [Column]
            public String BeschrijvingENG
            {
                get { return _BeschrijvingENG; }
                set
                {
                    NotifyPropertyChanging("BeschrijvingENG");
                    _BeschrijvingENG = value;
                    NotifyPropertyChanged("BeschrijvingENG");
                }
            }

            [Column]
            public String BeschrijvingNL
            {
                get { return _BeschrijvingNL; }
                set
                {
                    NotifyPropertyChanging("BeschrijvingNL");
                    _BeschrijvingNL = value;
                    NotifyPropertyChanged("BeschrijvingNL");
                }
            }

            [Column]
            public String TitelENG
            {
                get { return _TitelENG; }
                set
                {
                    NotifyPropertyChanging("TitelENG");
                    _TitelENG = value;
                    NotifyPropertyChanged("TitelENG");
                }
            }

            [Column]
            public String TitelNL
            {
                get { return _TitelNL; }
                set
                {
                    NotifyPropertyChanging("TitelNL");
                    _TitelNL = value;
                    NotifyPropertyChanged("TitelNL");
                }
            }

            #region INotifyPropertyChanged Members

            public event PropertyChangedEventHandler PropertyChanged;

            // Used to notify that a property changed 
            private void NotifyPropertyChanged(string propertyName)
            {
                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
                }
            }

            #endregion

            #region INotifyPropertyChanging Members

            public event PropertyChangingEventHandler PropertyChanging;

            // Used to notify that a property is about to change 
            private void NotifyPropertyChanging(string propertyName)
            {
                if (PropertyChanging != null)
                {
                    PropertyChanging(this, new PropertyChangingEventArgs(propertyName));
                }
            }

            #endregion
        }
        [Table]
        public class Bezienswaardigheid
        {
            // Define ID: private field, public property, and database column.
            private double _Lengtegraad;
            private double _Bretegraad;
            private string _BeschrijvingENG;
            private string _BeschrijvingNL;
            private string _TitelENG;
            private string _TitelNL;
            private string _Stad;
            private string _AbeeldingLocatie;


            [Column(IsPrimaryKey = true, IsDbGenerated = true)]
            public int BezienswaardigheidSleutel
            {
                get;
                internal set;
            }

            [Column]
            public double Lengtegraad
            {
                get { return _Lengtegraad; }
                set
                {
                    NotifyPropertyChanging("Lengtegraad");
                    _Lengtegraad = value;
                    NotifyPropertyChanged("Lengtegraad");
                }
            }

            [Column]
            public double Bretegraad
            {
                get { return _Bretegraad; }
                set
                {
                    NotifyPropertyChanging("Bretegraad");
                    _Bretegraad = value;
                    NotifyPropertyChanged("Bretegraad");
                }
            }

            [Column]
            public string Stad
            {
                get { return _Stad; }
                set
                {
                    NotifyPropertyChanging("Stad");
                    _Stad = value;
                    NotifyPropertyChanged("Stad");
                }
            }

            [Column]
            public String BeschrijvingENG
            {
                get { return _BeschrijvingENG; }
                set
                {
                    NotifyPropertyChanging("BeschrijvingENG");
                    _BeschrijvingENG = value;
                    NotifyPropertyChanged("BeschrijvingENG");
                }
            }

            [Column]
            public String BeschrijvingNL
            {
                get { return _BeschrijvingNL; }
                set
                {
                    NotifyPropertyChanging("BeschrijvingNL");
                    _BeschrijvingNL = value;
                    NotifyPropertyChanged("BeschrijvingNL");
                }
            }

            [Column]
            public String TitelENG
            {
                get { return _TitelENG; }
                set
                {
                    NotifyPropertyChanging("TitelENG");
                    _TitelENG = value;
                    NotifyPropertyChanged("TitelENG");
                }
            }

            [Column]
            public String TitelNL
            {
                get { return _TitelNL; }
                set
                {
                    NotifyPropertyChanging("TitelNL");
                    _TitelNL = value;
                    NotifyPropertyChanged("TitelNL");
                }
            }
            [Column]
            public String AbeeldingLocatie
            {
                get { return _AbeeldingLocatie; }
                set
                {
                    NotifyPropertyChanging("AbeeldingLocatie");
                    _AbeeldingLocatie = value;
                    NotifyPropertyChanged("AbeeldingLocatie");
                }
            }

            #region INotifyPropertyChanged Members

            public event PropertyChangedEventHandler PropertyChanged;

            // Used to notify that a property changed 
            private void NotifyPropertyChanged(string propertyName)
            {
                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
                }
            }

            #endregion

            #region INotifyPropertyChanging Members

            public event PropertyChangingEventHandler PropertyChanging;

            // Used to notify that a property is about to change 
            private void NotifyPropertyChanging(string propertyName)
            {
                if (PropertyChanging != null)
                {
                    PropertyChanging(this, new PropertyChangingEventArgs(propertyName));
                }
            }

            #endregion
        }

        [Table]
        public class Bezienswaardigheid_Route
        {
            private int _BezienswaardigheidSleutel;
            private int _RouteSleutel;
            private int _volgnummer;

            [Column(IsPrimaryKey = true, IsDbGenerated = true)]
            public int koppelsleutel
            {
                get;
                internal set;
            }

            [Column]
            public int RouteSleutel
            {
                get { return _RouteSleutel; }
                set { _RouteSleutel = value; }
            }
            [Column]
            public int volgnummer
            {
                get { return _volgnummer; }
                set { _volgnummer = value; }
            }

            [Column]
            public int BezienswaardigheidSleutel
            {
                get { return _BezienswaardigheidSleutel; }
                set { _BezienswaardigheidSleutel = value; }
            }
            //[Association(Storage = "sleutel", ThisKey = "koppelsleutel", OtherKey = "RouteSleutel" )]
            //private EntityRef<Route> sleutel;



            //[Association(Storage = "sleutel1", ThisKey = "koppelsleutel", OtherKey = "BezienswaardigheidSleutel")]
            //private EntityRef<Bezienswaardigheid> sleutel1;
        }
    }
}
